package com.xy_pro.xymanager.entity;

//import javax.persistence.Entity;
//import javax.persistence.GeneratedValue;
import jakarta.persistence.*;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.Date;

import static com.xy_pro.xymanager.helper.XYUtils.PASSWORD_RESET;

@Entity
@Table(name = "users", uniqueConstraints = {
        @UniqueConstraint(columnNames = "name")
})
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class UserEntity {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    @Column(unique = true, nullable = false)
    private String name;
    @Builder.Default
    private String password = PASSWORD_RESET;
//    @Builder.Default
//    private String role = ROLE_USER;;//角色,默认是学生
    private String sex;
    @Column(unique = true, nullable = false)
    private String phone;
    @Builder.Default
    private Date registerDate = new Date();
    private int age;

    @Enumerated(EnumType.STRING)
    private Role role = Role.ROLE_USER;

    // 角色枚举
    public enum Role {
        ROLE_USER,
        ROLE_ADMIN
    }

}
